<%@include file="../../context.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Company List</title>
<link href="<c:url value="/resources/css/backend/style.css" />"
	rel="stylesheet" type="text/css" /></link>
<%@include file="../common_Admin_imports.jsp"%>
<%@include file="../common_list_page.jsp"%>

<script type="text/javascript">
	$(document)
			.ready(
					function() {
						paginationNextBtn("${pageContext.request.contextPath}/admin/company/list.html?totalRecords=${companyPage.totalNoOfRecords}&page=");
					});
</script>
</head>
<body>
	<div class="main_wrapper">
		<div class="header_wrapper">
			<div class="container-fluid">
				<div class="header_inner_wrapper clearfix">
					<div class="row-fluid">
						<div class="header_left span4">List of company</div>
						<div class="header_right span8">
							<div class="input-append">
								<!-- search section -->

								<form:form method="POST" id="form_id" commandName="criteria"
									action="${pageContext.request.contextPath}/admin/company/search.html">
									<form:input onselect="" cssClass="searchSelector"
										list="companyNameList" path="companyName" />
									<form:input onselect="" cssClass="searchSelector"
										list="sectorNameList" path="sectorName" />
									<form:input onselect="" cssClass="searchSelector"
										list="subSectorNameList" path="subSectorName" />
									<input class="btnSerch btn-info" type="submit" value="Search" />
									<input id="reset_btn" class="btnSerch btn-info" type="button"
										value="Reset" />
								</form:form>
								<datalist id="sectorNameList">
									<c:forEach items="${sectorsMap}" var="sector">
										<option value="${sector.name }" />
									</c:forEach>
								</datalist>
								<datalist id="companyNameList">
									<c:forEach items="${companyMap}" var="company">
										<option value="${company.name }" />
									</c:forEach>
								</datalist>
								<datalist id="subSectorNameList">
									<c:forEach items="${subSectorsMap}" var="subSector">
										<option value="${subSector.name }" />
									</c:forEach>
								</datalist>
								<!-- end of search section -->
							</div>
							<jsp:include page="../common_link.jsp" />
						</div>
					</div>
				</div>

				<div class="row-fluid">
					<div class="main_table">
						<table class="table table-bordered table-striped">
							<thead>
								<tr>
									<th id="tableHeader">No</th>
									<th id="tableHeader">Company Name</th>
									<th id="tableHeader">Ticker</th>
									<th id="tableHeader">Sector</th>
									<th></th>
									<th></th>
								</tr>
							</thead>
							<tbody>
								<c:forEach var="company" items="${companyPage.pageData}">
									<tr>
										<td>${company.id}</td>
										<td>${company.name}</td>
										<td id="tableHeader">${company.code}</td>
										<td>${company.sector.name}</td>
										<td><a class="btn btn-info"
											href="${pageContext.request.contextPath}/admin/company/edit/${company.id}.html">Edit</a>
										</td>
										<td><a class="btn btn-danger"
											lang="${pageContext.request.contextPath}/admin/company/delete/${company.id}.html"
											href="javascript:void(0);"
											onclick="return confirmAndDelete(this);">Delete</a></td>
									</tr>
								</c:forEach>
							</tbody>
						</table>

						<!-- paging section -->
						<div class="pagination pagination-right">
							<!-- page number -->
							Page&nbsp;<input value="${companyPage.currentPageNo}"
								style="width: 50px;" type="number" min="0"
								max="${companyPage.totalNoOfPages }" id="pageNum">
							<!-- end page number -->
							<ul>
								<li><c:if test="${companyPage.showPrev}">
										<a
											href="${pageContext.request.contextPath}/admin/company/list.html?page=${companyPage.currentPageNo-1}&totalRecords=${companyPage.totalNoOfRecords}">Prev</a>
									</c:if></li>
								<c:forEach begin="${companyPage.startPageNo}" var="page"
									end="${companyPage.endPageNo}">
									<li><a
										<c:if test="${companyPage.currentPageNo==page}">style="background-color:#79BAEC"</c:if>
										href="${pageContext.request.contextPath}/admin/company/list.html?page=${page}&totalRecords=${companyPage.totalNoOfRecords}">${page}</a></li>&nbsp;
							</c:forEach>
								<li><c:if test="${companyPage.showNext}">
										<a
											href="${pageContext.request.contextPath}/admin/company/list.html?page=${companyPage.currentPageNo+1}&totalRecords=${companyPage.totalNoOfRecords}">Next</a>
									</c:if></li>
								<li><a class="pageCountLink">${companyPage.totalNoOfPages }
										Pages</a></li>
							</ul>

						</div>
						<div>
							<br></br>
						</div>
						<!-- paging section -->
						<a class="btn btn-success"
							href="${pageContext.request.contextPath}/admin/company/add.html">New</a>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>